using UnityEngine;
using System.Collections;
using System.Collections.Generic;

[ExecuteInEditMode]
public class UISort : MonoBehaviour
{
	
	public double behindZ = 0;
	public const float BEHIND_STEP = 0.000001f;
	public const float BEHIND_STEP_D = BEHIND_STEP * 100.0f;

	// Use this for initialization
	void Start ()
	{
		List<GameObject> gameObjectSort = GameObjectUtils.getChildrenGameObjectSort (gameObject);
		float behind = (float)behindZ;
		int lastIndex = gameObjectSort.Count - 1;
		for (; lastIndex >= 0; lastIndex--) {
			Transform trans = gameObjectSort [lastIndex].transform;
			Vector3 localPosition = trans.localPosition;
			localPosition.z = behind;
			trans.localPosition = localPosition;
			behind += BEHIND_STEP;
		}
	}
}
